36
Inheritance and
is-a relationship
“Is-a'' also implies, that we can use a circle everywhere where a point is expected. For example, write a function or method, say move(), which should move a point in x direction can be written as follows.
move(Point apoint, int deltax) {
apoint.setX(apoint.getX() + deltax)
}
As a circle inherits from a point, you can use this function with a circle argument to move its center point and, hence, the whole circle:
Circle acircle
...
move(acircle, 10) /* Move circle by moving */
/* its center point */